package com.junqson.je.content.repo;

import com.junqson.je.content.model.PostModel;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.util.Date;

/**
 * @Descriptions
 * @Company
 * @Author Junqson
 * @Date 2020/2/10 23:43
 * @Version 1.0
 */
@Repository
public interface PostRepo extends JpaRepository<PostModel, Long> {

    @Transactional
    @Modifying
    @Query("update PostModel m set m.updateTime=?1 where postId=?2")
    void changeUpdateTime(Date time, Long postId);

    Page<PostModel> findBySection(String section, Pageable pageable);

}
